{extend name='common/_container'} {block name="content"}
<div class="row">
	<div class="col-sm-12">
		<div class="ibox float-e-margins">
			<div class="ibox-content">
				<div class="row row-lg">
					<div class="col-sm-12">
						<div class="row" id="searchGroup">
							<div class="col-sm-2">
		<!--						<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">昵称</button>
									</div>
									<input type="text" autocomplete="off" class="form-control" id="nickname" placeholder="昵称" />
								</div>
							</div>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">手机号</button>
									</div>
									<input type="text" autocomplete="off" class="form-control" id="phone" placeholder="手机号" />
								</div>
							</div>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">状态</button>
									</div>
									<select class="form-control" id="status">
										<option value="">请选择</option>
										<option value="1">正常</option>
										<option value="0">拉黑</option>
									</select>
								</div>
							</div>-->
						<!--	<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">是否红娘</button>
									</div>
									<input type="text" autocomplete="off" class="form-control" id="is_matchmaker" placeholder="是否红娘" />
								</div>
							</div>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">是否会员</button>
									</div>
									<input type="text" autocomplete="off" class="form-control" id="is_vip" placeholder="是否会员" />
								</div>
							</div>
							<div class="col-sm-2">
								<div class="input-group">
									<div class="input-group-btn">
										<button data-toggle="dropdown" class="btn btn-white dropdown-toggle" type="button">会员卡号</button>
									</div>
									<input type="text" autocomplete="off" class="form-control" id="vip_number" placeholder="会员卡号" />
								</div>
							</div>-->
							<!-- search end -->
							<!--<div class="col-sm-1">
								<button type="button" class="btn btn-success " onclick="CodeGoods.search()" id="">
									<i class="fa fa-search"></i>&nbsp;搜索
								</button>
							</div>-->
						</div>
						<div class="btn-group-sm" id="CodeGoodsTableToolbar" role="group">

						</div>
						<table id="CodeGoodsTable" data-mobile-responsive="true" data-click-to-select="true">
							<thead><tr><th data-field="selectItem" data-checkbox="true"></th></tr></thead>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
	var CodeGoods = {id: "CodeGoodsTable",seItem: null,table: null,layerIndex: -1};

	CodeGoods.initColumn = function () {
		return [
			{title: '编号', field: 'uid', visible: true, align: 'center', valign: 'middle',sortable: true},
			{title: '昵称', field: 'nickname', visible: true, align: 'center', valign: 'middle',sortable: true},
			{title: '头像', field: 'avatar', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.avatarFormatter},
			{title: '余额', field: 'balance', visible: true, align: 'center', valign: 'middle',sortable: true},
			{title: '手机号', field: 'phone', visible: true, align: 'center', valign: 'middle',sortable: true},
			{title: '照片', field: 'pic', visible: false, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.picFormatter},
		/*	{title: '上级红娘', field: 'matchmaker_id', visible: true, align: 'center', valign: 'middle',sortable: true},
			{title: '是否红娘', field: 'is_matchmaker', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.is_matchmakerFormatter},
			{title: '是否会员', field: 'is_vip', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.is_vipFormatter},
			{title: '是否认证', field: 'is_auth', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.is_authFormatter},
*/			{title: '审核状态', field: 'auth_status', visible: true, align: 'center', valign: 'middle',sortable: true,formatter:CodeGoods.auth_statusFormatter},
		];
	};

	CodeGoods.buttonFormatter = function(value,row,index) {
		if(row.uid){
			var str= '';
			{if condition="in_array('backend/Member/view',session('backend.nodes')) || session('backend.role_id') eq 1"}
			str += '<button type="button" class="btn btn-info btn-xs" title="查看详情"  onclick="CodeGoods.view('+row.uid+')"><i class="fa fa-eye"></i>&nbsp;查看详情</button>&nbsp;';
			{/if}
				{if condition="in_array('backend/Member/update',session('backend.nodes')) || session('backend.role_id') eq 1"}
				str += '<button type="button" class="btn btn-success btn-xs" title="修改"  onclick="CodeGoods.update('+row.uid+')"><i class="fa fa-pencil"></i>&nbsp;修改</button>&nbsp;';
				{/if}
					return str;
				}
			}

			CodeGoods.avatarFormatter = function(value,row,index) {
				if(value){
					return "<a href=\"javascript:void(0)\" onclick=\"openImg('"+value+"')\"><img height='30' src="+value+"></a>";
				}
			}

			CodeGoods.picFormatter = function(value,row,index) {
				if(value){
					return "<a href=\"javascript:void(0)\" onclick=\"openImg('"+value+"')\"><img height='30' src="+value+"></a>";
				}
			}
			CodeGoods.is_matchmakerFormatter = function(value,row,index) {
				if(value){
					return '<span class="btn btn-success">' + '是' + '</span>';
				}else{
					return '<span class="btn btn-warning">' + '否' + '</span>';
				}
			}

			CodeGoods.is_authFormatter = function(value,row,index) {
				if(value){
					return '<span class="btn btn-success">' + '是' + '</span>';
				}else{
					return '<span class="btn btn-warning">' + '否' + '</span>';
				}
			}

			CodeGoods.is_vipFormatter = function(value,row,index) {
				if(value){
					return '<span class="btn btn-success">' + '是' + '</span>';
				}else{
					return '<span class="btn btn-warning">' + '否' + '</span>';
				}
			}

			CodeGoods.statusFormatter = function(value,row,index) {
				if(value !== null){
					if(value == 1){
						return '<input class="mui-switch mui-switch-animbg status'+row.uid+'" type="checkbox" onclick="CodeGoods.updatestatus('+row.uid+',0,\'status\')" checked>';
					}else{
						return '<input class="mui-switch mui-switch-animbg status'+row.uid+'" type="checkbox" onclick="CodeGoods.updatestatus('+row.uid+',1,\'status\')">';
					}
				}
			}



			CodeGoods.auth_statusFormatter = function(value,row,index) {
				if(value == 1){
					return '<span class="btn btn-success">' + '待审核' + '</span>';
				}else if(value == 2) {
					return '<span class="btn btn-warning">' + '通过' + '</span>';
				}else if(value == 3) {
					return '<span class="btn btn-warning">' + '已拒绝' + '</span>';
				}
			}

			CodeGoods.formParams = function() {
				var queryData = {};
				queryData['offset'] = 0;
				queryData['nickname'] = $("#nickname").val();
				queryData['phone'] = $("#phone").val();
				queryData['status'] = $("#status").val();
				queryData['is_matchmaker'] = $("#is_matchmaker").val();
				queryData['is_vip'] = $("#is_vip").val();
				queryData['vip_number'] = $("#vip_number").val();
				return queryData;
			}

			CodeGoods.check = function () {
				var selected = $('#' + this.id).bootstrapTable('getSelections');
				if(selected.length == 0){
					Feng.info("请先选中表格中的某一记录！");
					return false;
				}else{
					CodeGoods.seItem = selected;
					return true;
				}
			};




			CodeGoods.search = function() {
				CodeGoods.table.refresh({query : CodeGoods.formParams()});
			};

			$(function() {
				var defaultColunms = CodeGoods.initColumn();
				var url = location.search;
				var table = new BSTable(CodeGoods.id, Feng.ctxPath+"/ZhMatchmaker/childList"+url,defaultColunms,20);
				table.setPaginationType("server");
				table.setQueryParams(CodeGoods.formParams());
				CodeGoods.table = table.init();
			});
</script>
{/block}